// 必须在文件顶部添加这行导入！
import { createRouter, createWebHistory } from 'vue-router'
const router = createRouter({
  history: createWebHistory(),
  routes: [
    // 管理端路由入口（需管理员权限）
    {
      path: '/admin',
      name: 'admin',
      component: () => import('@/components/layout/AppLayout.vue'), // 管理端布局组件
      meta: { requiresAuth: true, roles: ['admin'] },    // 需登录且角色为admin
      children:[
        // 企业档案相关
        {
          path: '/archive',
          name: 'archive',
          component: () => import('@/views/Enterprise/ArchiveView.vue') // 企业档案页面
        },
        // 企业服务相关
        {
          path: '/service',
          name:'service',
          component: () => import('@/views/Enterprise/ServiceView.vue') // 企业服务页面
        },
        // 招商线索管理
        {
          path:'/clue_management',
          name:'clue_management',
          component:()=>import('@/views/Investment/Clue_Management.vue') // 线索管理页面
        },
        // 租赁场所数据看板
        {
          path: '/dashboard',
          name:'dashboard',
          component: () => import('@/views/RentPlace/DashBoard.vue') // 数据仪表盘页面
        },
        // 租赁销售服务管理
        {
          path: '/salesservicemanagement',
          name:'salesservicemanagement',
          component: () => import('@/views/RentPlace/SalesServiceManagement.vue') // 销售服务管理页面
        },
        // 付款账单生成
        {
          path:'/paybillmaker',
          name:'paybillmaker',
          component:()=>import('@/views/RentMoney/PayBillMaker.vue') // 付款账单生成页面
        },
        // 合同审批相关
        {
          path:'/approval',
          name:'approval',
          component:()=>import('@/views/Contract/Approval.vue') // 合同审批页面
        },
        // 合同变更记录
        {
          path:'/change-record',
          name:'change-record',
          component:()=>import('@/views/Contract/ChangeRecord.vue') // 合同变更记录页面
        },
        // 合同列表
        {
          path:'/contract-list',
          name:'contract-list',
          component:()=>import('@/views/Contract/List.vue') // 合同列表页面
        },
        // 合同模板管理
        {
          path:'/template',
          name:'template',
          component:()=>import('@/views/Contract/Template.vue') // 合同模板页面
        },
        // 已签约项目
        {
          path:'/construction',
          name:'construction',
          component:()=>import('@/views/Project/Construction.vue') // 已签约项目页面
        },
        // 资源列表
        {
          path:'/resource-list',
          name:'resource-list',
          component:()=>import('@/views/Resource/List.vue') // 资源列表页面
        },
        // 房间管理
        {
          path:'/room-management',
          name:'room-management',
          component:()=>import('@/views/Resource/RoomManagement.vue') // 房间管理页面
        },
        // 土地审批
        {
          path:'/landapproval',
          name:'landapproval',
          component:()=>import('@/views/Project/LandApproval.vue') // 土地审批页面
        },
        // 竣工核查
        {
          path:'/completedcheck',
          name:'completedcheck',
          component:()=>import('@/views/Project/CompletedCheck.vue') // 竣工核查页面
        },
        // 洽谈中项目
        {
          path:'/negotiating',
          name:'negotiating',
          component:()=>import('@/views/Project/Negotiating.vue') // 洽谈中项目页面
        },
        // 洽谈中项目详情
        {
          path: '/project/in-talk/:id',
          name: 'InTalkProjectDetail',
          component:()=>import('@/views/Project/InTalkProjectDetail.vue') // 洽谈中项目详情页（带项目ID参数）
        },
        // 已签约项目详情
        {
          path: '/project/signed/:id',
          name: 'SignedProjectDetail',
          component:()=>import('@/views/Project/SignedProjectDetail.vue') // 已签约项目详情页（带项目ID参数）
        },
        // 文件审批
        {
          path:'/fileapproval',
          name:'fileapproval',
          component:()=>import('@/views/Project/FileApproval.vue') // 文件审批页面
        },
        // 项目分配跟进人
        {
          path: '/project/:id/assign',
          name: 'ProjectAssign',
          component: () => import('@/views/Project/AssignFollower.vue'),
          props: true // 自动将路由参数作为props传递给组件
        },
        // 编辑项目
        {
          path: '/projects/:id/edit',
          name: 'ProjectEdit',
          component: () => import('@/views/project/ProjectEdit.vue'),
          meta: { title: '编辑项目' } // 页面标题元信息
        },
        // 新建项目
        {
          path: '/projects/new',
          name: 'ProjectNew',
          component: () => import('@/views/project/ProjectEdit.vue'),
          meta: { title: '新建项目' } // 页面标题元信息
        },
        // 项目跟进
        {
          path: '/project/:id/follow-up',
          name: 'ProjectFollowUp',
          component: () => import('@/views/Project/FollowUp.vue'),
          meta: { title: '项目跟进' } // 页面标题元信息
        },
        // 签订合同
        {
          path: '/project/:id/sign-contract',
          name: 'SignContract',
          component: () => import('@/views/Project/SignContract.vue'),
          meta: {
            title: '签订合同',
            requiresAuth: true // 需登录权限
          }
        },
        //通知公告
        {
          path: '/notice/announcement',
          name: 'announcement',
          component: () => import('@/views/Notice/Announcement.vue')
        },
        //发布通知
        {
          path: '/notice/publish',
          name: 'noticePublish',
          component: () => import('@/views/Notice/AnnouncementRealse.vue')
        },
        //文件传阅
        {
          path: '/notice/circulation',
          name: 'circulation',
          component: () => import('@/views/Notice/Circulation.vue')
        }

      ]
    },
    // 登录页面
    {
      path: '/login',
      name: 'login',
      component: ()=>import('@/views/Login.vue'),
      meta: {
        hideLayout: true // 隐藏布局组件的元信息
      }
    },
    // 首页
    {
      path: '/',
      name: 'smartparkhome',
      component: () => import('@/views/Home/SmartParkHomeView.vue'), // 智慧园区首页
    },
    // Deepseek相关页面（企业端）
    {
      path: '/deepseek',
      name: 'deepseek',
      component: () => import('@/views/Enterprise/DeepseekView.vue'),
    },

    // 客户端路由入口（需客户端权限）
    {
      path: '/client',
      name: 'client',
      component: () => import('@/components/layout/AppLayoutClient.vue'), // 客户端布局组件
      meta: { requiresAuth: true, roles: ['client'] },    // 需登录且角色为client
      children:[
        // 公司注册流程相关
        {
          path: '/register',
          name: 'register',
          component: () => import('@/views/Enterprise/RegisterView.vue') // 公司注册页面
        },
        // 合同签订页面（接收公司名称、信用代码参数）
        {
          path: '/contract/:companyName?/:creditCode?',
          name: 'Contract',
          component: () => import('@/views/Enterprise/ContractView.vue'),
          props: true // 将路由参数作为props传递给组件
        },
        // 注册成功页面
        {
          path:'/success/:companyId?/:companyName?',
          name:'success',
          component:()=>import('@/views/Enterprise/SuccessView.vue') // 申请成功页面
        },
        //房间管理页面
        {
          path:'/manageroom',
          name:'manageroom',
          component:()=>import('@/views/Resource/RoomManagementClient.vue')
        },

        // 企业资料编辑
        {
          path:'/modifydata',
          name:'modifydata',
          component:()=>import('@/views/Enterprise/ModifyData.vue') // 编辑企业资料页面
        },
        // 公司账单页面
        {
          path: '/companybill',
          name:'companybill',
          component: () => import('@/views/Enterprise/CompanyBillView.vue') // 公司账单展示页面
        },
        // 招商门户
        {
          path:'/portal',
          name:'portal',
          component:()=>import('@/views/Investment/Portal.vue') // 招商门户页面
        },
        // 线索相关
        {
          path:'/clue',
          name:'clue',
          component:()=>import('@/views/Investment/Clue.vue') // 线索页面
        },
        // 我的线索
        {
          path: '/clue/personal',
          name: 'PersonalClue',
          component: ()=>import('@/views/Investment/PersonalClue.vue'),
          meta: { title: '我的线索' } // 页面标题元信息
        },
        // 线索页面重定向
        {
          path: '/clue',
          redirect: '/clue' // 重定向到线索页面
        },
        //合同申请客户端
        {
          path:'/contractside',
          name:'contractside',
          component:()=>import('@/views/Contract/ContractSide.vue')
        },
        {
          path:'/contractapply',
          name:'contractapply',
          component:()=>import('@/views/Contract/ContractApply.vue')
        },
        // 客户端项目申请办理
        {
          path:'/clientside',
          name:'clientside',
          component:()=>import('@/views/Project/ClientSide.vue') // 客户端项目办理入口
        },
        // 独立项目相关
        {
          path:'/independent',
          name:'independent',
          component:()=>import('@/views/Project/Independent.vue') // 独立项目页面
        },
        // 租赁项目相关
        {
          path:'/rental',
          name:'rental',
          component:()=>import('@/views/Project/Rental.vue') // 租赁项目页面
        },
        // 独立项目申请
        {
          path:'/indepenapply',
          name:'indepenapply',
          component:()=>import('@/views/Project/IndepenApply.vue') // 独立项目申请页面
        },
        // 租赁项目申请
        {
          path:'/rentalapply',
          name:'rentalapply',
          component:()=>import('@/views/Project/RentalApply.vue') // 租赁项目申请页面
        },
        // 客户端项目详情
        {
          path:'/clientprojectdetail',
          name:'clientprojectdetail',
          component:()=>import('@/views/Project/ClientProjectDetail.vue') // 客户端项目详情页
        },
        // 公司租赁信息提交页面
        {
          path: '/enterpriserentalsubmission',
          name: 'enterpriserentalsubmission',
          component: () => import('@/views/RentPlace/EnterpriseRentalSubmission.vue') // 企业租赁信息提交页
        },
        //通知公告
        {
          path: '/notice/announcementclient',
          name: 'announcementclient',
          component: () => import('@/views/Notice/AnnouncementClient.vue')
        },
        //发布通知
        {
          path: '/notice/publishclient',
          name: 'noticePublishclient',
          component: () => import('@/views/Notice/PublishClient.vue')
        },
        //文件传阅
        {
          path: '/notice/circulationclient',
          name: 'circulationclient',
          component: () => import('@/views/Notice/CirculationClient.vue')
        }
      ]

    },
    {
      path: '/announcement-detail/:announcementId',
      name: 'AnnouncementDetail',
      component: () => import('@/views/Notice/AnnouncementDetail.vue')
    }
  ]
})

export default router  